package com.pj.hellomvvm.viewmodel

import androidx.lifecycle.MutableLiveData
import com.blankj.utilcode.util.LogUtils
import com.pj.common.base.BaseViewModel

class TestRecyclerViewModel:BaseViewModel() {
    val list = MutableLiveData<MutableList<String>>()
    var pageNum = 1
    fun loadData(refresh:Boolean = true){
        if (refresh){
            pageNum = 1
//            noData.postValue(false)
//            hasMore.postValue(true)
            hasMoreData(true)
            list.postValue(arrayListOf("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"))
        }else{
            val lst = mutableListOf<String>()
            val start = (pageNum*10+11)
            for (i in start until start+10)
                lst.add("$i")
            pageNum += 1
            list.postValue(lst)
            if (pageNum>3){
                LogUtils.e("没有数据了")
                hasMoreData(false)
            }
        }
    }
}